package com.inns.position.hbase;

import com.google.protobuf.ByteString;
import com.inns.position.hbase.config.properties.InnsProperties;
import com.inns.position.hbase.coprocessor.service.ObserverStatisticsProtos;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by phoenix on 2018/4/14.
 */
public class HbaseConsts {

    public static boolean autoCreateTable = true;

    public static final String TableName_Original = "inns_location";
    public static final String TableName_Period = "inns_period";

    public static final String TableName_Statistics_BuildId = "stat_build";
    public static final String TableName_Statistics_POI = "stat_poi";
    public static final String TableName_Statistics_User = "stat_user";
    public static final String TableName_Statistics_Duration_Frag_BuildId = "stat_dur_build";
    public static final String TableName_Statistics_Duration_Frag_POI = "stat_dur_poi";
    public static final String TableName_Statistics_Frequency_Frag_BuildId = "stat_freq_build";
    public static final String TableName_Statistics_Frequency_Frag_POI = "stat_freq_poi";
    public static final String TableName_Statistics_User_Frequency_Tag = "stat_user_Tag";
    public static final String TableName_Statistics_Path = "stat_path";

    public static List<String> statisticsTables = new ArrayList<>();

    static {
        statisticsTables.add(TableName_Statistics_BuildId);
        statisticsTables.add(TableName_Statistics_POI);
        statisticsTables.add(TableName_Statistics_User);
        statisticsTables.add(TableName_Statistics_Duration_Frag_BuildId);
        statisticsTables.add(TableName_Statistics_Duration_Frag_POI);
        statisticsTables.add(TableName_Statistics_Frequency_Frag_BuildId);
        statisticsTables.add(TableName_Statistics_Frequency_Frag_POI);
        statisticsTables.add(TableName_Statistics_User_Frequency_Tag);
        statisticsTables.add(TableName_Statistics_Path);
    }

    public static final String FamilyColumn = "info";
    public static final ByteString family = ByteString.copyFromUtf8(FamilyColumn);
    public static final ByteString IMSI = ByteString.copyFromUtf8("IMSI");
    public static final ByteString buildId = ByteString.copyFromUtf8("buildId");
    public static final ByteString poiId = ByteString.copyFromUtf8("poiId");
    public static final ByteString x = ByteString.copyFromUtf8("x");

    public static final ObserverStatisticsProtos.ExpandCell IMSICell = ObserverStatisticsProtos.ExpandCell.newBuilder().setFamily(family).setQualify(IMSI).build();
    public static final ObserverStatisticsProtos.ExpandCell buildIdCell = ObserverStatisticsProtos.ExpandCell.newBuilder().setFamily(family).setQualify(buildId).build();
    public static final ObserverStatisticsProtos.ExpandCell poiIdCell = ObserverStatisticsProtos.ExpandCell.newBuilder().setFamily(family).setQualify(poiId).build();
    public static final ObserverStatisticsProtos.ExpandCell xCell = ObserverStatisticsProtos.ExpandCell.newBuilder().setFamily(family).setQualify(x).build();

    public static final List<Float> intervalList = Arrays.asList(0.5f, 1f, 2f, 4f);

    public static int SPLIT_TIME() {
        return InnsProperties.instance().getOfflineTime() * 1000;
    }

    public static int MIN_STAT_TIME() {
        return InnsProperties.instance().getMinTime() * 1000;
    }

    public static final int ONE_MINUTE = 60 * 1000;
    public static final int ONE_HOUR = 3600 * 1000;
    public static final int ONE_DAY = 24 * ONE_HOUR;
    public static final int ONE_WEEK = 7 * ONE_DAY;
    public static final long SIX_MONTH = 6L * 30 * ONE_DAY;
}
